<template>
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
    <a-input v-model:value="link" />
    <el-button @click="touchCopy">复制链接</el-button>
  </div>
</template>

<script setup>
import { ref } from 'vue'
// 导入插件
import useClipboard from 'vue-clipboard3'
import {message} from "ant-design-vue";

// 点击复制
function touchCopy () {
  // 调用
  copy(link.value)
}
// 使用插件
const { toClipboard } = useClipboard()
const link = ref('')
const copy = async (msg) => {
  try {
    // 复制
    await toClipboard(msg)
    message.success('复制成功')
    // 复制成功
  } catch (e) {
    // 复制失败
    throw e
  }
}
</script>
